package com.jpcc.vw.onlineRadio.utils;


import android.text.TextUtils;

import com.jpcc.vw.onlineRadio.application.MusicApplication;
import com.jpcc.vw.onlineRadio.model.bean.RecentAlbumRadioTrackBean;
import com.jpcc.vw.onlineRadio.model.bean.Track;

public class Track2RecentAlbumTrackUtils {
    public static RecentAlbumRadioTrackBean Track2RecentBean(Track track) {
        if (track == null) {
            return null;
        } else {
            RecentAlbumRadioTrackBean result = new RecentAlbumRadioTrackBean();
            result.setUserId(MusicApplication.GetUserId());
            result.setAlbumId(track.getSubordinatedAlbum().getId());
            result.setAlbumName(track.getSubordinatedAlbum().getAlbumTitle());
            result.setAuthor(track.getAnnouncer().getNickname());
            result.setTrackId(track.getId());
            result.setTrackName(track.getTrackTitle());
            result.setCover(track.getCoverUrlLarge());
//            if(!TextUtils.isEmpty(track.getPlayUrlAmr())){
//                result.setTrackUrl(track.getPlayUrlAmr());
//            }
//            else{
//                result.setTrackUrl(track.getPlayUrl32());
//            }
            result.setTrackUrl(track.getPlayUrl32());
            result.setDuration((int)track.getDuration()*1000);
            result.setCanDownLoad(track.isCanDownload());
            result.setDownloadUrl(track.getDownloadUrl());
            result.setType(track.type);
            result.setLive(track.isLive());
            result.setStartTime(track.getStartTime());
            result.setEndTime(track.getEndString());
            result.setIs_authorized(track.isIs_authorized());
            result.setIs_free(track.isIs_free());
            result.setIs_paid(track.isIs_paid());
            result.setVipFree(track.isVIPFree());
            return result;
        }
    }



    public static RecentAlbumRadioTrackBean Track2RecentBeanListenback(Track track) {
        if (track == null) {
            return null;
        } else {
            RecentAlbumRadioTrackBean result = new RecentAlbumRadioTrackBean();
            result.setUserId(MusicApplication.GetUserId());
            result.setAlbumId(track.getSubordinatedAlbum().getId());
            result.setAlbumName(track.getSubordinatedAlbum().getAlbumTitle());
            result.setAuthor(track.getAnnouncer().getNickname());
            result.setTrackId(track.getId());
            result.setTrackName(track.getTrackTitle());
            result.setCover(track.getCoverUrlLarge());
            result.setTrackUrl(track.getPlayUrl32());
            result.setDuration((int)track.getDuration()*1000);
            result.setCanDownLoad(track.isCanDownload());
            result.setDownloadUrl(track.getDownloadUrl());
            result.setType(track.type);
            result.setLive(track.isLive());
            return result;
        }
    }
}
